//
//  PTMarkingLabel.m
//  pet120
//
//  Created by 方力 on 15/8/14.
//  Copyright (c) 2015年 Mac. All rights reserved.
//

#import "PTMarkingLabel.h"

@interface PTMarkingLabel()



@property(nonatomic,strong)UIImage * bgImage;
@end

@implementation PTMarkingLabel




-(id)init
{
    if (self) {
        self=[super init];
        
        
        self.bgImageView=[[UIImageView alloc] init];
//        self.bgImageView.frame=CGRectMake(self.origin.x-5, self.origin.y-5, self.width+10, self.height+20);
        
        [self.superview addSubview:self.bgImageView];
         self.bgImageView.contentMode=UIViewContentModeScaleToFill;
    }

    
    return self;

}


-(instancetype)initWithFrame:(CGRect)frame
{
    if (self) {
        self=[super initWithFrame:frame];
        
        self.bgImageView=[[UIImageView alloc] init];
//        self.bgImageView.frame=CGRectMake(self.origin.x-5, self.origin.y-5, self.width+10, self.height+20);
        
        [self.superview addSubview:self.bgImageView];
        
        self.bgImageView.contentMode=UIViewContentModeScaleToFill;
    }


    return self;



}


-(instancetype)initWithCoder:(NSCoder *)aDecoder
{



    if (self) {
        self=[super initWithCoder:aDecoder];
        
        self.bgImageView=[[UIImageView alloc] init];
//        self.bgImageView.frame=CGRectMake(self.origin.x-5, self.origin.y-5, self.width+10, self.height+20);
        
        [self.superview addSubview:self.bgImageView];
        
        self.bgImageView.contentMode=UIViewContentModeScaleToFill;
        
        
//        self.bgImageView.backgroundColor=[UIColor redColor];
    }
    
    
    return self;

}




- (void)drawRect:(CGRect)rect {
    
    [super drawRect:rect];
    

  
  //  [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(animates) userInfo:nil repeats:YES];
}



-(void)setText:(NSString *)text
{

    [super setText:text];
    
    
    
    
    if (text.length>20) {
        
        text=[text substringToIndex:20];
        
        text=[NSString stringWithFormat:@"%@...",text];
        
        
    }
    
    
    
    
    
    

  //  CGSize size = CGSizeMake(kUI_SCREEN_WIDTH-self.left-10,2000);
    UIFont *font = [UIFont fontWithName:@"Arial" size:14];
    self.numberOfLines=0;
  //  CGSize labelsize = [text sizeWithFont:font constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];

    self.font=font;
    self.textColor=[UIColor lightGrayColor];
    self.backgroundColor=[UIColor clearColor];

    
    

//        UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)
    
       // self.bgImage=[[UIImage imageNamed:@"bq"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 4) resizingMode:UIImageResizingModeStretch];
        

    self.bgImage=[UIImage imageNamed:@"bq"];
        
        self.bgImageView.frame=self.superview.bounds;
        
        
        self.bgImageView.image=self.bgImage;
        
        self.alpha=1;
        self.bgImageView.alpha=1;
        
    
    
    
//    self.bgImageView.width=self.bgImageView.width-10;
    
    

        [self.superview addSubview:self.bgImageView];
    

    
    
}





@end
